<script setup lang="ts">
import { useAttrStore } from '@/stores/modules/attr';
import { onMounted } from 'vue';

const props=defineProps({
    screen:Number
})

const attrStore=useAttrStore()
//获取二级分类
const changeValue1=()=>{
    //清空二级三级的数据
    attrStore.c2Id=''
    attrStore.thirdCateList=[]
    attrStore.c3Id=''
    attrStore.getSecondCateData(attrStore.c1Id as number)
}

//获取三级分类
const changeValue2=async()=>{
    attrStore.c3Id=''
    attrStore.getThirdCateData(attrStore.c2Id as number)
}

const changeValue3=async()=>{
   
}
onMounted(()=>{
    attrStore.getFirstCateData()
})
</script>

<template>
    <el-card>
        <el-form inline>
            <el-form-item label="一级分类">
                <el-select placeholder="请选择" style="width: 200px;" v-model="attrStore.c1Id" @change="changeValue1" :disabled="props.screen==0? false:true">
                    <el-option v-for="item in attrStore.firstCateList" :key="item.id" :value="item.id" :label="item.name"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="二级分类" style="margin-left: 20px;">
                <el-select placeholder="请选择" style="width: 200px;" v-model="attrStore.c2Id" @change="changeValue2" :disabled="props.screen==0? false:true">
                    <el-option v-for="item in attrStore.secondCateList" :key="item.id" :value="item.id" :label="item.name"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="三级分类" style="margin-left: 20px;">
                <el-select placeholder="请选择" style="width: 200px;" v-model="attrStore.c3Id" @change="changeValue3" :disabled="props.screen==0? false:true">
                    <el-option v-for="item in attrStore.thirdCateList" :key="item.id" :value="item.id" :label="item.name"></el-option>
                </el-select>
            </el-form-item>
        </el-form>
    </el-card>
</template>

<style lang="scss" scoped></style>